// MProgram.h: Definition of the CMProgram class
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MPROGRAM_H__1B6ED7C8_EB38_11D1_BF0B_0000B4560A15__INCLUDED_)
#define AFX_MPROGRAM_H__1B6ED7C8_EB38_11D1_BF0B_0000B4560A15__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CMProgram

extern "C" void _free_program PROT((program_t *o));

class CMProgram : 
	public CComDualImpl<IMProgram, &IID_IMProgram, &LIBID_MUDOSLib>, 
	public ISupportErrorInfo,
	public CComObjectRoot,
	public CComCoClass<CMProgram,&CLSID_MProgram>
{
private:
	object_t  *obj;
public:

	CMProgram() {obj=NULL;}
	void Create(object_t *p){if(obj)_free_object(obj,"CMProgram:Create");obj=p;obj->ref++;}
	~CMProgram() {if(obj)_free_object(obj,"~CMProgram");}
	void Assign(CMProgram *p){Create(p->obj);}
	program_t *GetProg(){return obj->prog;}
	object_t *GetOb(){return obj;}
BEGIN_COM_MAP(CMProgram)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IMProgram)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
//DECLARE_NOT_AGGREGATABLE(CMProgram) 
// Remove the comment from the line above if you don't want your object to 
// support aggregation. 

DECLARE_REGISTRY(CMProgram, _T("Mudos.MProgram.1"), _T("Mudos.MProgram"), IDS_MPROGRAM_DESC, THREADFLAGS_BOTH)
// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IMProgram
public:
	STDMETHOD(get_FileName)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(get_Function)(/*[in]*/ int id, /*[out, retval]*/ IMFunction * *pVal);
	STDMETHOD(get_FunctionCount)(/*[out, retval]*/ int *pVal);
};

#endif // !defined(AFX_MPROGRAM_H__1B6ED7C8_EB38_11D1_BF0B_0000B4560A15__INCLUDED_)
